* ======================================
* --------- Sample Politicians ---------
* ======================================
* Creates a balanced panel of politicians in 2015 and 2019 ("universe")


	use "$dta/ImportPoliticians.dta",clear
	
	
* Restrict sample
* ===============
	
	* Local candidate in 2015, 2019
	keep if year == 2015 | year == 2019
	keep if running_loc == 1
	drop if running_reg == 1
	
	* "Big 9" parties
	gen main_loc = 0
	foreach p in a frp h krf sp rodt sv v mdg{
		replace main_loc = 1 if party_loc == "`p'" 
	}
	keep if main_loc == 1
	
	* Import geography
	merge 1:1 idPers year using $dta\ImportGeo.dta, keep(master matched) nogen
	drop if knr == "" // a few without address

	
* Rename variables
* ================

	rename idPers Polit_id
	rename running_loc Polit_Run
	rename elected_loc Polit_Win
	rename rank_loc Polit_Rank
	rename rankpct_loc Polit_RankPct
	rename party_loc Polit_Party
	rename preadvantage_loc Polit_Bonus
	rename bsu Polit_bsu
	rename knr Polit_knr
	keep year Polit*

	
	save $dta\PanelPoliticians.dta, replace
